<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <!--<link rel="shortcut icon" th:href="@{/favicon.ico}"/>-->
    <title>登录</title>
    <!--  <link rel="stylesheet" type="text/css" th:href="@{/css/base.css}">
      <link rel="stylesheet" type="text/css" th:href="@{/css/login.css}">-->
</head>
<body>
用户名: <input type="text" id="userName"><br>
密&emsp;码:<input type="password" id="userPwd"><br>
<input type="button" value="登录" th:onclick="login()">
</body>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<script>
    function login() {
        var params = {};
        params.userName = $("#userName").val();
        params.userPwd = $("#userPwd").val();
        $.ajax({
            type: "post",
            url: "/login",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(params),
            success: function (data) {
                if (data.success) {
                    window.location.href = "/index.html";
                }
            }
        })
    }
</script>
</html>